import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;

public class ShoppingCart implements Dao{//201621123021 简卓林
    private ArrayList<Good> goods = new ArrayList<>();
    public void add(Good good){ //购买商品==将商品放入购物车
        goods.add(good);
    }

    @Override
    public String toString() {
        return "ShoppingCart{" +
                "goods=" + goods +
                "}";
    }
    public BigDecimal sum(){
        BigDecimal res = new BigDecimal(0);
        for (Good good : goods) {
            res=res.add(good.getPrice());
        }
        return res;
    }

    public void deleteGood(int index){
        goods.remove(index-1);
    }
    public void deleteGood(Good o){
        goods.remove(o);
    }
}
